import React, { useEffect } from 'react'
import { BrowserRouter } from 'react-router-dom'
import { ConfigProvider } from 'antd'
import zhCN from 'antd/es/locale/zh_CN'
import moment from 'moment'
import 'moment/locale/zh-cn'
import RenderRouter from './routes'

const App: React.FC = () => {
  useEffect(() => {
    console.log('location', location)
    if (location.search) {
      history.replaceState('', '', `${location.origin}${location.pathname}`)
    }
    // if (!window.localStorage.getItem('isLogin') && !window.localStorage.getItem('isFirstLogin')) {
    //   window.localStorage.setItem('isFirstLogin', 'true')
    //   window.location.replace('/login')
    // }
    moment.locale('zh-cn')
  }, [])

  return (
    <ConfigProvider locale={zhCN} componentSize="middle">
      <BrowserRouter>
        <RenderRouter />
      </BrowserRouter>
    </ConfigProvider>
  )
}

export default App
